const { minify } = require('terser')
const code = `
let aaa = 1
let bbb = 1
console.log(aaa)
console.log(bbb)
`
async function foo() {
    const res = await minify(code, {
        toplevel: true
    })
    console.log(res.code)
}
foo()